from fastapi import APIRouter, Request

from applications.configs.func import render_template
from applications.configs.response import ResponseMessage
from applications.schemas.Aigc import AigcBaseModel
from applications.services.aigc import chat_send_message_func

aigc_router = APIRouter(prefix="/aigc", tags=["AI管理器"])


@aigc_router.get("/", summary='aigc首页', description="aigc首页")
def index(request: Request):
    aigc_list = [
        {"name": "ai聊天", "url": "/aigc/chat", "remark": "各大ai聊天软件集合"},
        {"name": "pdf工具集合", "url": "/aigc/pdf", "remark": "pdf文件解析成文本"}
    ]
    return render_template(request, "/aigc/index.html", {"aigc_list": aigc_list})


@aigc_router.get("/chat", summary='ai聊天页面', description="ai聊天页面")
def chat_html(request: Request):
    return render_template(request, "/aigc/chat.html")


@aigc_router.post("/send_message", summary='发送消息', description="发送消息")
def chat_send_message(data: AigcBaseModel):
    code, msg = chat_send_message_func(data)
    return ResponseMessage(code, msg)